package ru.hh.school.commands;

import ru.hh.school.RoomManager;
import ru.hh.school.User;
import ru.hh.school.logging.Logger;

import static ru.hh.school.Constants.LINE_SEPARATOR;
import static ru.hh.school.util.ResourceManager.message;
import static ru.hh.school.util.StringUtils.join;

public class ListRoomCommand extends Command {
    private final String listOfAllRoomsString;

    public ListRoomCommand(Logger logger, RoomManager manager) {
        super(logger);
        String listOfAllRoomNamesString = join(manager.getRoomNames(), LINE_SEPARATOR);
        this.listOfAllRoomsString = message("command.list.notify.user.list.of.all.rooms", listOfAllRoomNamesString);
    }

    public String getCommand() {
        return "/rooms";
    }

    public String getDescription() {
        return message("command.list.description");
    }

    public void process(User user, String data) {
        user.sendMessage(listOfAllRoomsString);
    }
}